package com.sdry.service.impl.lqy;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sdry.mapper.hpf.AllReportMapper;
import com.sdry.mapper.hpf.PositionMapper;
import com.sdry.mapper.hpf.ProductMapper;
import com.sdry.mapper.llm.TeamRecordMapper;
import com.sdry.mapper.lqy.WeeklyreportMapper;
import com.sdry.model.hpf.Position;
import com.sdry.model.hpf.Product;
import com.sdry.model.hpf.ProductStatus;
import com.sdry.model.hpf.StationStatus;
import com.sdry.model.jyy.Cut;
import com.sdry.model.jyy.Shedudetail;
import com.sdry.model.jyy.Solid;
import com.sdry.model.llm.Classes;
import com.sdry.model.llm.TeamRecord;
import com.sdry.model.lqy.AllWorkstation;
import com.sdry.model.lqy.Workstation;
import com.sdry.model.lqy.WorkstationDetail;
import com.sdry.model.lqy.Worktime;
import com.sdry.model.lqy.Worktimes;
import com.sdry.model.workplace.Assemble;
import com.sdry.model.workplace.Centrifugal;
import com.sdry.model.workplace.MousseBundleSample;
import com.sdry.model.zc.ZcEvaluateEntity;
import com.sdry.model.zc.ZcGasEntity;
import com.sdry.model.zc.ZcLeakHuntingEntity;
import com.sdry.service.llm.ClassesService;
import com.sdry.service.lqy.WeeklyProductionReportService;
import com.sdry.utils.DateUtil;
import com.sdry.utils.WorkstationUtil;

@Service
public class WeeklyProductionReportServiceImpl implements WeeklyProductionReportService {

	@Resource
	private WeeklyreportMapper weeklyreport;
	@Resource
	private PositionMapper positionMapper;
	@Resource
	private WeeklyProductionReportService weeklyproductionreport;
	@Resource
	private AllReportMapper allReportMapper;
	@Resource
	private TeamRecordMapper teamRecordMapper;
	@Resource
	private ClassesService classesService;

	@Override
	public Map<String, Object> Dayreport(String Sdate, Long tids) {
		Map<String, Object> map = new HashMap();
		Map<String, Object> map1 = new HashMap();
		map.put("sid", tids);
		map.put("Dates", Sdate);
		String tid = weeklyreport.Dayreport(map);
		map1.put("plan", tid);
		map1.put("Date", Sdate);
		return map1;
	}

	@Override
	public Map<String, Object> Weeklyreport(String Sdate, Long tids) {
		Map<String, Object> map = new HashMap();
		Map<String, Object> map1 = new HashMap();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date date = null;
		try {
			date = sdf.parse(Sdate);
		} catch (Exception e) {
			e.printStackTrace();
		}
		// Calendar cal = Calendar.getInstance();
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		cal.setFirstDayOfWeek(Calendar.MONDAY);
		int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
		if (dayWeek == 1) {
			dayWeek = 8;
		}
		cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - dayWeek);// 根据日历的规则，给当前日期减去星期几与一个星期第一天的差值
		Date mondayDate = cal.getTime();
		String weekBegin = sdf.format(mondayDate);
		cal.add(Calendar.DATE, 4 + cal.getFirstDayOfWeek());
		Date sundayDate = cal.getTime();
		String weekEnd = sdf.format(sundayDate);
		map.put("mondayDate", weekBegin);
		map.put("sundayDate", weekEnd);
		map.put("tid", tids);
		List<String> tid = new ArrayList<>();
		tid = weeklyreport.Weeklyreport(map);
		map1.put("plan", tid);
		map1.put("mondayDate", weekBegin);
		map1.put("sundayDate", weekEnd);
		return map1;
	}

	@Override
	public Long PlanId(String team) {
		Map<String, Object> map = new HashMap();
		map.put("team", team);
		return weeklyreport.PlanId(map);
	}

	@Override
	public List<StationStatus> Planreport(String Sdate, String team) {
		Shedudetail shedudetail = new Shedudetail();
		Shedudetail reshedudetail = new Shedudetail();
		Map<String, Object> map1 = new HashMap();
		List<String> Sid = new ArrayList<>();
		DecimalFormat decimalFormat = new DecimalFormat(".00");
		Long tids = weeklyproductionreport.PlanId(team);
		map1 = weeklyproductionreport.Weeklyreport(Sdate, tids);
		Sid = (List<String>) map1.get("plan");
		String datebeginStr = (String) map1.get("mondayDate");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date begin = null;
		try {
			begin = sdf.parse(datebeginStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		int E1 = 0, B1 = 0, C1 = 0, D1 = 0;
		for (String s : Sid) {
			reshedudetail = weeklyreport.Planreport(Long.parseLong(s));
			String E11 = null, B11 = null, C11 = null, D11 = null;
			if (null == reshedudetail) {
				E11 = B11 = C11 = D11 = "0";
			} else {
				if (null == reshedudetail.getE1() || reshedudetail.getE1().equals("")) {
					E11 = "0";
				} else {
					E11 = reshedudetail.getE1();
				}
				if (null == reshedudetail.getB1() || reshedudetail.getB1().equals("")) {
					B11 = "0";
				} else {
					B11 = reshedudetail.getB1();
				}
				if (null == reshedudetail.getC1() || reshedudetail.getC1().equals("")) {
					C11 = "0";
				} else {
					C11 = reshedudetail.getC1();
				}
				if (null == reshedudetail.getD1() || reshedudetail.getD1().equals("")) {
					D11 = "0";
				} else {
					D11 = reshedudetail.getD1();
				}
			}
			E1 += Integer.parseInt(E11);
			B1 += Integer.parseInt(B11);
			C1 += Integer.parseInt(C11);
			D1 += Integer.parseInt(D11);

		}
		String E2 = String.valueOf(E1);
		String B2 = String.valueOf(B1);
		String C2 = String.valueOf(C1);
		String D2 = String.valueOf(D1);
		if (E2.equals("0")) {
			E2 = "";
		}
		if (B2.equals("0")) {
			B2 = "";
		}
		if (C2.equals("0")) {
			C2 = "";
		}
		if (D2.equals("0")) {
			D2 = "";
		}
		shedudetail.setE1(E2);
		shedudetail.setB1(B2);
		shedudetail.setC1(C2);
		shedudetail.setD1(D2);
		List<StationStatus> stationStatusList = new ArrayList<>();
		String[] stationName = { "膜丝", "组装", "离心", "固化", "切割" };

		List<MousseBundleSample> msList = new ArrayList<>();
		List<Assemble> zzList = new ArrayList<>();
		List<Solid> ghList = new ArrayList<>();
		List<Cut> qgList = new ArrayList<>();
		List<Centrifugal> lxList = new ArrayList<>();
		if (null != shedudetail) {
			Map<String, Object> map = new HashMap<>();

			Calendar c = Calendar.getInstance();
			c.setTime(begin);
			for (int i = 1; i < 8; i++) {
				datebeginStr = sdf.format(c.getTime());
				if (team.equals("白班")) {
					map.put("beginTime", datebeginStr + " 08:00:00");
					Calendar cc = Calendar.getInstance();
					cc.setTime(c.getTime());
					cc.add(Calendar.DAY_OF_MONTH, 1);
					String dateendStr = sdf.format(cc.getTime());
					map.put("endTime", dateendStr + " 20:00:00");
				}
				if (team.equals("夜班")) {
					map.put("beginTime", datebeginStr + " 20:00:00");
					Calendar cc = Calendar.getInstance();
					cc.setTime(c.getTime());
					cc.add(Calendar.DAY_OF_MONTH, 1);
					String dateendStr = sdf.format(cc.getTime());
					map.put("endTime", dateendStr + "08:00:00 ");
				}
				List<MousseBundleSample> msList1 = allReportMapper.listAllMSByTime(map);
				List<Assemble> zzList1 = allReportMapper.listAllZZByTime(map);
				List<Centrifugal> lxList1 = allReportMapper.listAllLXByTime(map);
				List<Solid> ghList1 = allReportMapper.listAllGHByTime(map);
				List<Cut> qgList1 = allReportMapper.listAllCutByTime(map);
				msList.addAll(msList1);
				zzList.addAll(zzList1);
				lxList.addAll(lxList1);
				ghList.addAll(ghList1);
				qgList.addAll(qgList1);
				c.add(Calendar.DAY_OF_MONTH, 1);
			}
			String b1 = shedudetail.getB1();// 0960T 个数
			String c1 = shedudetail.getC1();// 0980T 个数
			String d1 = shedudetail.getD1();// 1080C 个数
			String e1 = shedudetail.getE1();// 1060B 个数
			// 计算膜丝工位每个产品的生产状况
			StationStatus stationStatus1 = new StationStatus();
			stationStatus1.setStationName(stationName[0]);
			List<ProductStatus> productStatusList1 = new ArrayList<>();
			ProductStatus productStatus11 = new ProductStatus();
			productStatus11.setPname("0960外压组件");
			int ms1 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("01".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus11.setPlanAmount(0);
				productStatus11.setLastPlanAmount(0 - ms1);
				productStatus11.setProductivity(0 + "");
			} else {
				productStatus11.setPlanAmount((Integer.parseInt(b1)) * 24);
				productStatus11.setLastPlanAmount(((Integer.parseInt(b1)) * 24) - ms1);
				productStatus11
						.setProductivity(decimalFormat.format((double) ms1 * 100 / (Integer.parseInt(b1) * 24)) + "%");
			}
			productStatus11.setCompleteAmount(ms1);
			productStatusList1.add(productStatus11);
			ProductStatus productStatus12 = new ProductStatus();
			productStatus12.setPname("0980外压组件");
			int ms2 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("02".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus12.setPlanAmount(0);
				productStatus12.setLastPlanAmount(0 - ms2);
				productStatus12.setProductivity(0 + "");
			} else {
				productStatus12.setPlanAmount((Integer.parseInt(c1)) * 24);
				productStatus12.setLastPlanAmount(((Integer.parseInt(c1)) * 24) - ms2);
				productStatus12
						.setProductivity(decimalFormat.format((double) ms2 * 100 / (Integer.parseInt(c1) * 24)) + "%");
			}
			productStatus12.setCompleteAmount(ms2);
			productStatusList1.add(productStatus12);
			ProductStatus productStatus13 = new ProductStatus();
			productStatus13.setPname("1080组件");
			int ms3 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("04".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus13.setPlanAmount(0);
				productStatus13.setLastPlanAmount(0 - ms3);
				productStatus13.setProductivity(0 + "");
			} else {
				productStatus13.setPlanAmount((Integer.parseInt(d1)) * 32);
				productStatus13.setLastPlanAmount(((Integer.parseInt(d1)) * 32) - ms3);
				productStatus13
						.setProductivity(decimalFormat.format((double) ms3 * 100 / (Integer.parseInt(d1) * 32)) + "%");

			}
			productStatus13.setCompleteAmount(ms3);
			productStatusList1.add(productStatus13);
			ProductStatus productStatus14 = new ProductStatus();
			productStatus14.setPname("1060组件");
			int ms4 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("03".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus14.setPlanAmount(0);
				productStatus14.setLastPlanAmount(0 - ms4);
				productStatus14.setProductivity(0 + "");
			} else {
				productStatus14.setPlanAmount((Integer.parseInt(e1)) * 32);
				productStatus14.setLastPlanAmount(((Integer.parseInt(e1)) * 32) - ms4);
				productStatus14
						.setProductivity(decimalFormat.format((double) ms4 * 100 / (Integer.parseInt(e1) * 32)) + "%");
			}
			productStatus14.setCompleteAmount(ms4);
			productStatusList1.add(productStatus14);
			stationStatus1.setProductStatusList(productStatusList1);
			stationStatusList.add(stationStatus1);
			// 计算组装工位每个产品的生产状况
			StationStatus stationStatus2 = new StationStatus();
			stationStatus2.setStationName(stationName[1]);
			List<ProductStatus> productStatusList2 = new ArrayList<>();
			ProductStatus productStatus21 = new ProductStatus();
			productStatus21.setPname("0960外压组件");
			int zz1 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("0960".equals(assemble.getAtube().substring(3, 7))) {
					zz1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus21.setPlanAmount(0);
				productStatus21.setLastPlanAmount(0 - zz1);
				productStatus21.setProductivity(0 + "");
			} else {
				productStatus21.setPlanAmount(Integer.parseInt(b1));
				productStatus21.setLastPlanAmount(Integer.parseInt(b1) - zz1 / 24);
				productStatus21
						.setProductivity(decimalFormat.format((double) zz1 * 100 / 24 / Integer.parseInt(b1)) + "%");
			}
			productStatus21.setCompleteAmount(zz1 / 24);
			productStatusList2.add(productStatus21);
			ProductStatus productStatus22 = new ProductStatus();
			productStatus22.setPname("0980外压组件");
			int zz2 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("0980".equals(assemble.getAtube().substring(3, 7))) {
					zz2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus22.setPlanAmount(0);
				productStatus22.setLastPlanAmount(0 - zz2);
				productStatus22.setProductivity(0 + "");
			} else {
				productStatus22.setPlanAmount(Integer.parseInt(c1));
				productStatus22.setLastPlanAmount(Integer.parseInt(c1) - zz2 / 24);
				productStatus22
						.setProductivity(decimalFormat.format((double) zz2 * 100 / 24 / Integer.parseInt(c1)) + "%");
			}
			productStatus22.setCompleteAmount(zz2 / 24);
			productStatusList2.add(productStatus22);
			ProductStatus productStatus23 = new ProductStatus();
			productStatus23.setPname("1080组件");
			int zz3 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("1080".equals(assemble.getAtube().substring(3, 7))) {
					zz3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus23.setPlanAmount(0);
				productStatus23.setLastPlanAmount(0 - zz3);
				productStatus23.setProductivity(0 + "");
			} else {
				productStatus23.setPlanAmount(Integer.parseInt(d1));
				productStatus23.setLastPlanAmount(Integer.parseInt(d1) - zz3 / 32);
				productStatus23
						.setProductivity(decimalFormat.format((double) zz3 * 100 / 32 / Integer.parseInt(d1)) + "%");
			}
			productStatus23.setCompleteAmount(zz3 / 32);
			productStatusList2.add(productStatus23);
			ProductStatus productStatus24 = new ProductStatus();
			productStatus24.setPname("1060组件");
			int zz4 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("1060".equals(assemble.getAtube().substring(3, 7))) {
					zz4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus24.setPlanAmount(0);
				productStatus24.setLastPlanAmount(0 - zz4);
				productStatus24.setProductivity(0 + "");
			} else {
				productStatus24.setPlanAmount(Integer.parseInt(e1));
				productStatus24.setLastPlanAmount(Integer.parseInt(e1) - zz4 / 32);
				productStatus24
						.setProductivity(decimalFormat.format((double) zz4 * 100 / 32 / Integer.parseInt(e1)) + "%");
			}
			productStatus24.setCompleteAmount(zz4 / 24);
			productStatusList2.add(productStatus24);
			stationStatus2.setProductStatusList(productStatusList2);
			stationStatusList.add(stationStatus2);
			// 计算离心工位每个产品的生产状况
			StationStatus stationStatus3 = new StationStatus();
			stationStatus3.setStationName(stationName[2]);
			List<ProductStatus> productStatusList3 = new ArrayList<>();
			ProductStatus productStatus31 = new ProductStatus();
			productStatus31.setPname("0960外压组件");
			int lx1 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("0960".equals(centrifugal.getCtube().substring(3, 7))) {
					lx1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus31.setPlanAmount(0);
				productStatus31.setLastPlanAmount(0 - lx1);
				productStatus31.setProductivity(0 + "");
			} else {
				productStatus31.setPlanAmount(Integer.parseInt(b1));
				productStatus31.setLastPlanAmount(Integer.parseInt(b1) - lx1);
				productStatus31.setProductivity(decimalFormat.format((double) lx1 * 100 / Integer.parseInt(b1)) + "%");
			}
			productStatus31.setCompleteAmount(lx1);
			productStatusList3.add(productStatus31);
			ProductStatus productStatus32 = new ProductStatus();
			productStatus32.setPname("0980外压组件");
			int lx2 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("0980".equals(centrifugal.getCtube().substring(3, 7))) {
					lx2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus32.setPlanAmount(0);
				productStatus32.setLastPlanAmount(0 - lx2);
				productStatus32.setProductivity(0 + "");
			} else {
				productStatus32.setPlanAmount(Integer.parseInt(c1));
				productStatus32.setLastPlanAmount(Integer.parseInt(c1) - lx2);
				productStatus32.setProductivity(decimalFormat.format((double) lx2 * 100 / Integer.parseInt(c1)) + "%");
			}
			productStatus32.setCompleteAmount(lx2);
			productStatusList3.add(productStatus32);
			ProductStatus productStatus33 = new ProductStatus();
			productStatus33.setPname("1080组件");
			int lx3 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("1080".equals(centrifugal.getCtube().substring(3, 7))) {
					lx3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus33.setPlanAmount(0);
				productStatus33.setLastPlanAmount(0 - lx3);
				productStatus33.setProductivity(0 + "");
			} else {
				productStatus33.setPlanAmount(Integer.parseInt(d1));
				productStatus33.setLastPlanAmount(Integer.parseInt(d1) - lx3);
				productStatus33.setProductivity(decimalFormat.format((double) lx3 * 100 / Integer.parseInt(d1)) + "%");
			}
			productStatus33.setCompleteAmount(lx3);
			productStatusList3.add(productStatus33);
			ProductStatus productStatus34 = new ProductStatus();
			productStatus34.setPname("1060组件");
			int lx4 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("1060".equals(centrifugal.getCtube().substring(3, 7))) {
					lx4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus34.setPlanAmount(0);
				productStatus34.setLastPlanAmount(0 - lx4);
				productStatus34.setProductivity(0 + "");
			} else {
				productStatus34.setPlanAmount(Integer.parseInt(e1));
				productStatus34.setLastPlanAmount(Integer.parseInt(e1) - lx4);
				productStatus34.setProductivity(decimalFormat.format((double) lx4 * 100 / Integer.parseInt(e1)) + "%");
			}
			productStatus34.setCompleteAmount(lx4);
			productStatusList3.add(productStatus34);
			stationStatus3.setProductStatusList(productStatusList3);
			stationStatusList.add(stationStatus3);
			// 计算固化工位每个产品的生产状况
			StationStatus stationStatus4 = new StationStatus();
			stationStatus4.setStationName(stationName[3]);
			List<ProductStatus> productStatusList4 = new ArrayList<>();
			ProductStatus productStatus41 = new ProductStatus();
			productStatus41.setPname("0960外压组件");
			int gh1 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("0960".equals(solid.getStube().substring(3, 7))) {
					gh1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus41.setPlanAmount(0);
				productStatus41.setLastPlanAmount(0 - gh1);
				productStatus41.setProductivity(0 + "");
			} else {
				productStatus41.setPlanAmount(Integer.parseInt(b1));
				productStatus41.setLastPlanAmount(Integer.parseInt(b1) - gh1);
				productStatus41.setProductivity(decimalFormat.format((double) gh1 * 100 / Integer.parseInt(b1)) + "%");
			}
			productStatus41.setCompleteAmount(gh1);
			productStatusList4.add(productStatus41);
			ProductStatus productStatus42 = new ProductStatus();
			productStatus42.setPname("0980外压组件");
			int gh2 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("0980".equals(solid.getStube().substring(3, 7))) {
					gh2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus42.setPlanAmount(0);
				productStatus42.setLastPlanAmount(0 - gh2);
				productStatus42.setProductivity(0 + "");
			} else {
				productStatus42.setPlanAmount(Integer.parseInt(c1));
				productStatus42.setLastPlanAmount(Integer.parseInt(c1) - gh2);
				productStatus42.setProductivity(decimalFormat.format((double) gh2 * 100 / Integer.parseInt(c1)) + "%");
			}
			productStatus42.setCompleteAmount(gh2);
			productStatusList4.add(productStatus42);
			ProductStatus productStatus43 = new ProductStatus();
			productStatus43.setPname("1080组件");
			int gh3 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("1080".equals(solid.getStube().substring(3, 7))) {
					gh3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus43.setPlanAmount(0);
				productStatus43.setLastPlanAmount(0 - gh3);
				productStatus43.setProductivity(0 + "");
			} else {
				productStatus43.setPlanAmount(Integer.parseInt(d1));
				productStatus43.setLastPlanAmount(Integer.parseInt(d1) - gh3);
				productStatus43.setProductivity(decimalFormat.format((double) gh3 * 100 / Integer.parseInt(d1)) + "%");
			}
			productStatus43.setCompleteAmount(gh3);
			productStatusList4.add(productStatus43);
			ProductStatus productStatus44 = new ProductStatus();
			productStatus44.setPname("1060组件");
			int gh4 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("1060".equals(solid.getStube().substring(3, 7))) {
					gh4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus44.setPlanAmount(0);
				productStatus44.setLastPlanAmount(0 - gh4);
				productStatus44.setProductivity(0 + "");
			} else {
				productStatus44.setPlanAmount(Integer.parseInt(e1));
				productStatus44.setLastPlanAmount(Integer.parseInt(e1) - gh4);
				productStatus44.setProductivity(decimalFormat.format((double) gh4 * 100 / Integer.parseInt(e1)) + "%");
			}
			productStatus44.setCompleteAmount(gh4);
			productStatusList4.add(productStatus44);
			stationStatus4.setProductStatusList(productStatusList4);
			stationStatusList.add(stationStatus4);
			// 计算切割工位每个产品的生产状况
			StationStatus stationStatus5 = new StationStatus();
			stationStatus5.setStationName(stationName[4]);
			List<ProductStatus> productStatusList5 = new ArrayList<>();
			ProductStatus productStatus51 = new ProductStatus();
			productStatus51.setPname("0960外压组件");
			int qg1 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("0960".equals(cut.getCtube().substring(3, 7))) {
					qg1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus51.setPlanAmount(0);
				productStatus51.setLastPlanAmount(0 - qg1);
				productStatus51.setProductivity(0 + "");
			} else {
				productStatus51.setPlanAmount(Integer.parseInt(b1));
				productStatus51.setLastPlanAmount(Integer.parseInt(b1) - qg1);
				productStatus51.setProductivity(decimalFormat.format((double) qg1 * 100 / Integer.parseInt(b1)) + "%");
			}
			productStatus51.setCompleteAmount(qg1);
			productStatusList5.add(productStatus51);
			ProductStatus productStatus52 = new ProductStatus();
			productStatus52.setPname("0980外压组件");
			int qg2 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("0980".equals(cut.getCtube().substring(3, 7))) {
					qg2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus52.setPlanAmount(0);
				productStatus52.setLastPlanAmount(0 - qg2);
				productStatus52.setProductivity(0 + "");
			} else {
				productStatus52.setPlanAmount(Integer.parseInt(c1));
				productStatus52.setLastPlanAmount(Integer.parseInt(c1) - qg2);
				productStatus52.setProductivity(decimalFormat.format((double) qg2 * 100 / Integer.parseInt(c1)) + "%");
			}
			productStatus52.setCompleteAmount(qg2);
			productStatusList5.add(productStatus52);
			ProductStatus productStatus53 = new ProductStatus();
			productStatus53.setPname("1080组件");
			int qg3 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("1080".equals(cut.getCtube().substring(3, 7))) {
					qg3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus53.setPlanAmount(0);
				productStatus53.setLastPlanAmount(0 - qg3);
				productStatus53.setProductivity(0 + "");
			} else {
				productStatus53.setPlanAmount(Integer.parseInt(d1));
				productStatus53.setLastPlanAmount(Integer.parseInt(d1) - qg3);
				productStatus53.setProductivity(decimalFormat.format((double) qg3 * 100 / Integer.parseInt(d1)) + "%");
			}
			productStatus53.setCompleteAmount(qg3);
			productStatusList5.add(productStatus53);
			ProductStatus productStatus54 = new ProductStatus();
			productStatus54.setPname("1060组件");
			int qg4 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("1060".equals(cut.getCtube().substring(3, 7))) {
					qg4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus54.setPlanAmount(0);
				productStatus54.setLastPlanAmount(0 - qg4);
				productStatus54.setProductivity(0 + "");
			} else {
				productStatus54.setPlanAmount(Integer.parseInt(e1));
				productStatus54.setLastPlanAmount(Integer.parseInt(e1) - qg4);
				productStatus54.setProductivity(decimalFormat.format((double) qg4 * 100 / Integer.parseInt(e1)) + "%");
			}
			productStatus54.setCompleteAmount(qg4);
			productStatusList5.add(productStatus54);
			stationStatus5.setProductStatusList(productStatusList5);
			stationStatusList.add(stationStatus5);
			return stationStatusList;
		} else {
			// 排产单不存在
			return stationStatusList;
		}
	}

	@Override
	public List<StationStatus> Comprehensivereport(String Sdate, String team) {
		DecimalFormat decimalFormat = new DecimalFormat(".00");
		Map<String, Object> map1 = new HashMap();
		List<StationStatus> stationStatusList = new ArrayList<>();
		Shedudetail shedudetail = new Shedudetail();
		Long tids = weeklyproductionreport.PlanId(team);
		map1 = weeklyproductionreport.Dayreport(Sdate, tids);

		String plan = (String) map1.get("plan");
		if (null == plan || plan.equals("")) {
			return stationStatusList;
		}
		String datebeginStr = (String) map1.get("Date");
		shedudetail = weeklyreport.Planreport(Long.parseLong(plan));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Map<String, Object> map2 = new HashMap<>();
		if (team.equals("白班")) {
			map2.put("beginTime", datebeginStr + " 08:00:00");
			map2.put("endTime", datebeginStr + " 19:59:59");
		}
		if (team.equals("晚班")) {
			map2.put("beginTime", datebeginStr + " 20:00:00");
			Date begin = null;
			try {
				begin = sdf.parse(datebeginStr);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			Calendar cc = Calendar.getInstance();
			cc.setTime(begin);
			cc.add(Calendar.DAY_OF_MONTH, 1);
			String dateendStr = sdf.format(cc.getTime());
			map2.put("endTime", dateendStr + " 07:59:59");
		}

		String number = weeklyproductionreport.Comprehensivenumber(map2);

		String[] stationName = { "膜丝", "组装", "离心", "固化", "切割" };
		if (null != shedudetail) {
			Map<String, Object> map = new HashMap<>();
			if (team.equals("白班")) {
				map.put("beginTime", datebeginStr + " 08:00:00");
				map.put("endTime", datebeginStr + " 19:59:59");
			}
			if (team.equals("晚班")) {
				map.put("beginTime", datebeginStr + " 20:00:00");
				Date begin = null;
				try {
					begin = sdf.parse(datebeginStr);
				} catch (ParseException e) {
					e.printStackTrace();
				}
				Calendar cc = Calendar.getInstance();
				cc.setTime(begin);
				cc.add(Calendar.DAY_OF_MONTH, 1);
				String dateendStr = sdf.format(cc.getTime());
				map.put("endTime", dateendStr + " 07:59:59");
			}
			List<MousseBundleSample> msList = allReportMapper.listAllMSByTime(map);
			List<Assemble> zzList = allReportMapper.listAllZZByTime(map);
			List<Centrifugal> lxList = allReportMapper.listAllLXByTime(map);
			List<Solid> ghList = allReportMapper.listAllGHByTime(map);
			List<Cut> qgList = allReportMapper.listAllCutByTime(map);
			String b1 = shedudetail.getB1();// 0960T 个数
			String c1 = shedudetail.getC1();// 0980T 个数
			String d1 = shedudetail.getD1();// 1080C 个数
			String e1 = shedudetail.getE1();// 1060B 个数
			// 计算膜丝工位每个产品的生产状况
			StationStatus stationStatus1 = new StationStatus();
			stationStatus1.setStationName(stationName[0]);
			List<ProductStatus> productStatusList1 = new ArrayList<>();
			ProductStatus productStatus11 = new ProductStatus();
			productStatus11.setPname("0960外压组件");
			int ms1 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("01".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus11.setPlanAmount(0);
				productStatus11.setLastPlanAmount(0 - ms1);
				productStatus11.setProductivity(0 + "");
			} else {
				productStatus11.setPlanAmount((Integer.parseInt(b1)) * 24);
				productStatus11.setLastPlanAmount(((Integer.parseInt(b1)) * 24) - ms1);
				productStatus11
						.setProductivity(decimalFormat.format((double) ms1 * 100 / (Integer.parseInt(b1) * 24)) + "%");
			}
			productStatus11.setCompleteAmount(ms1);
			productStatusList1.add(productStatus11);
			ProductStatus productStatus12 = new ProductStatus();
			productStatus12.setPname("0980外压组件");
			int ms2 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("02".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus12.setPlanAmount(0);
				productStatus12.setLastPlanAmount(0 - ms2);
				productStatus12.setProductivity(0 + "");
			} else {
				productStatus12.setPlanAmount((Integer.parseInt(c1)) * 24);
				productStatus12.setLastPlanAmount(((Integer.parseInt(c1)) * 24) - ms2);
				productStatus12
						.setProductivity(decimalFormat.format((double) ms2 * 100 / (Integer.parseInt(c1) * 24)) + "%");
			}
			productStatus12.setCompleteAmount(ms2);
			productStatusList1.add(productStatus12);
			ProductStatus productStatus13 = new ProductStatus();
			productStatus13.setPname("1080组件");
			int ms3 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("04".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus13.setPlanAmount(0);
				productStatus13.setLastPlanAmount(0 - ms3);
				productStatus13.setProductivity(0 + "");
			} else {
				productStatus13.setPlanAmount((Integer.parseInt(d1)) * 32);
				productStatus13.setLastPlanAmount(((Integer.parseInt(d1)) * 32) - ms3);
				productStatus13
						.setProductivity(decimalFormat.format((double) ms3 * 100 / (Integer.parseInt(d1) * 32)) + "%");
			}
			productStatus13.setCompleteAmount(ms3);
			productStatusList1.add(productStatus13);
			ProductStatus productStatus14 = new ProductStatus();
			productStatus14.setPname("1060组件");
			int ms4 = 0;
			for (int i = 0; i < msList.size(); i++) {
				MousseBundleSample mousseBundleSample = msList.get(i);
				if ("03".equals(mousseBundleSample.getMbscode().substring(2, 4))) {
					ms4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus14.setPlanAmount(0);
				productStatus14.setLastPlanAmount(0 - ms4);
				productStatus14.setProductivity(0 + "");
			} else {
				productStatus14.setPlanAmount((Integer.parseInt(e1)) * 32);
				productStatus14.setLastPlanAmount(((Integer.parseInt(e1)) * 32) - ms4);
				productStatus14
						.setProductivity(decimalFormat.format((double) ms4 * 100 / (Integer.parseInt(e1) * 32)) + "%");
			}
			productStatus14.setCompleteAmount(ms4);
			productStatusList1.add(productStatus14);
			stationStatus1.setProductStatusList(productStatusList1);
			stationStatusList.add(stationStatus1);
			// 计算组装工位每个产品的生产状况
			StationStatus stationStatus2 = new StationStatus();
			stationStatus2.setStationName(stationName[1]);
			List<ProductStatus> productStatusList2 = new ArrayList<>();
			ProductStatus productStatus21 = new ProductStatus();
			productStatus21.setPname("0960外压组件");
			int zz1 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("0960".equals(assemble.getAtube().substring(3, 7))) {
					zz1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus21.setPlanAmount(0);
				productStatus21.setLastPlanAmount(0 - zz1);
				productStatus21.setProductivity(0 + "");
			} else {
				productStatus21.setPlanAmount(Integer.parseInt(b1));
				productStatus21.setLastPlanAmount(Integer.parseInt(b1) - zz1 / 24);
				productStatus21
						.setProductivity(decimalFormat.format((double) zz1 * 100 / 24 / Integer.parseInt(b1)) + "%");
			}
			productStatus21.setCompleteAmount(zz1 / 24);
			productStatusList2.add(productStatus21);
			ProductStatus productStatus22 = new ProductStatus();
			productStatus22.setPname("0980外压组件");
			int zz2 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("0980".equals(assemble.getAtube().substring(3, 7))) {
					zz2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus22.setPlanAmount(0);
				productStatus22.setLastPlanAmount(0 - zz2);
				productStatus22.setProductivity(0 + "");
			} else {
				productStatus22.setPlanAmount(Integer.parseInt(c1));
				productStatus22.setLastPlanAmount(Integer.parseInt(c1) - zz2 / 24);
				productStatus22
						.setProductivity(decimalFormat.format((double) zz2 * 100 / 24 / Integer.parseInt(c1)) + "%");
			}
			productStatus22.setCompleteAmount(zz2 / 24);
			productStatusList2.add(productStatus22);
			ProductStatus productStatus23 = new ProductStatus();
			productStatus23.setPname("1080组件");
			int zz3 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("1080".equals(assemble.getAtube().substring(3, 7))) {
					zz3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus23.setPlanAmount(0);
				productStatus23.setLastPlanAmount(0 - zz3);
				productStatus23.setProductivity(0 + "");
			} else {
				productStatus23.setPlanAmount(Integer.parseInt(d1));
				productStatus23.setLastPlanAmount(Integer.parseInt(d1) - zz3 / 32);
				productStatus23
						.setProductivity(decimalFormat.format((double) zz3 * 100 / 32 / Integer.parseInt(d1)) + "%");
			}
			productStatus23.setCompleteAmount(zz3 / 32);
			productStatusList2.add(productStatus23);
			ProductStatus productStatus24 = new ProductStatus();
			productStatus24.setPname("1060组件");
			int zz4 = 0;
			for (int i = 0; i < zzList.size(); i++) {
				Assemble assemble = zzList.get(i);
				if ("1060".equals(assemble.getAtube().substring(3, 7))) {
					zz4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus24.setPlanAmount(0);
				productStatus24.setLastPlanAmount(0 - zz4);
				productStatus24.setProductivity(0 + "");
			} else {
				productStatus24.setPlanAmount(Integer.parseInt(e1));
				productStatus24.setLastPlanAmount(Integer.parseInt(e1) - zz4 / 32);
				productStatus24
						.setProductivity(decimalFormat.format((double) zz4 * 100 / 32 / Integer.parseInt(e1)) + "%");
			}
			productStatus24.setCompleteAmount(zz4 / 24);
			productStatusList2.add(productStatus24);
			stationStatus2.setProductStatusList(productStatusList2);
			stationStatusList.add(stationStatus2);
			// 计算离心工位每个产品的生产状况
			StationStatus stationStatus3 = new StationStatus();
			stationStatus3.setStationName(stationName[2]);
			List<ProductStatus> productStatusList3 = new ArrayList<>();
			ProductStatus productStatus31 = new ProductStatus();
			productStatus31.setPname("0960外压组件");
			int lx1 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("0960".equals(centrifugal.getCtube().substring(3, 7))) {
					lx1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus31.setPlanAmount(0);
				productStatus31.setLastPlanAmount(0 - lx1);
				productStatus31.setProductivity(0 + "");
			} else {
				productStatus31.setPlanAmount(Integer.parseInt(b1));
				productStatus31.setLastPlanAmount(Integer.parseInt(b1) - lx1);
				productStatus31.setProductivity(decimalFormat.format((double) lx1 * 100 / Integer.parseInt(b1)) + "%");
			}
			productStatus31.setCompleteAmount(lx1);
			productStatusList3.add(productStatus31);
			ProductStatus productStatus32 = new ProductStatus();
			productStatus32.setPname("0980外压组件");
			int lx2 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("0980".equals(centrifugal.getCtube().substring(3, 7))) {
					lx2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus32.setPlanAmount(0);
				productStatus32.setLastPlanAmount(0 - lx2);
				productStatus32.setProductivity(0 + "");
			} else {
				productStatus32.setPlanAmount(Integer.parseInt(c1));
				productStatus32.setLastPlanAmount(Integer.parseInt(c1) - lx2);
				productStatus32.setProductivity(decimalFormat.format((double) lx2 * 100 / Integer.parseInt(c1)) + "%");
			}
			productStatus32.setCompleteAmount(lx2);
			productStatusList3.add(productStatus32);
			ProductStatus productStatus33 = new ProductStatus();
			productStatus33.setPname("1080组件");
			int lx3 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("1080".equals(centrifugal.getCtube().substring(3, 7))) {
					lx3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus33.setPlanAmount(0);
				productStatus33.setLastPlanAmount(0 - lx3);
				productStatus33.setProductivity(0 + "");
			} else {
				productStatus33.setPlanAmount(Integer.parseInt(d1));
				productStatus33.setLastPlanAmount(Integer.parseInt(d1) - lx3);
				productStatus33.setProductivity(decimalFormat.format((double) lx3 * 100 / Integer.parseInt(d1)) + "%");
			}
			productStatus33.setCompleteAmount(lx3);
			productStatusList3.add(productStatus33);
			ProductStatus productStatus34 = new ProductStatus();
			productStatus34.setPname("1060组件");
			int lx4 = 0;
			for (int i = 0; i < lxList.size(); i++) {
				Centrifugal centrifugal = lxList.get(i);
				if ("1060".equals(centrifugal.getCtube().substring(3, 7))) {
					lx4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus34.setPlanAmount(0);
				productStatus34.setLastPlanAmount(0 - lx4);
				productStatus34.setProductivity(0 + "");
			} else {
				productStatus34.setPlanAmount(Integer.parseInt(e1));
				productStatus34.setLastPlanAmount(Integer.parseInt(e1) - lx4);
				productStatus34.setProductivity(decimalFormat.format((double) lx4 * 100 / Integer.parseInt(e1)) + "%");
			}
			productStatus34.setCompleteAmount(lx4);
			productStatusList3.add(productStatus34);
			stationStatus3.setProductStatusList(productStatusList3);
			stationStatusList.add(stationStatus3);
			// 计算固化工位每个产品的生产状况
			StationStatus stationStatus4 = new StationStatus();
			stationStatus4.setStationName(stationName[3]);
			List<ProductStatus> productStatusList4 = new ArrayList<>();
			ProductStatus productStatus41 = new ProductStatus();
			productStatus41.setPname("0960外压组件");
			int gh1 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("0960".equals(solid.getStube().substring(3, 7))) {
					gh1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus41.setPlanAmount(0);
				productStatus41.setLastPlanAmount(0 - gh1);
				productStatus41.setProductivity(0 + "");
			} else {
				productStatus41.setPlanAmount(Integer.parseInt(b1));
				productStatus41.setLastPlanAmount(Integer.parseInt(b1) - gh1);
				productStatus41.setProductivity(decimalFormat.format((double) gh1 * 100 / Integer.parseInt(b1)) + "%");
			}
			productStatus41.setCompleteAmount(gh1);
			productStatusList4.add(productStatus41);
			ProductStatus productStatus42 = new ProductStatus();
			productStatus42.setPname("0980外压组件");
			int gh2 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("0980".equals(solid.getStube().substring(3, 7))) {
					gh2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus42.setPlanAmount(0);
				productStatus42.setLastPlanAmount(0 - gh2);
				productStatus42.setProductivity(0 + "");
			} else {
				productStatus42.setPlanAmount(Integer.parseInt(c1));
				productStatus42.setLastPlanAmount(Integer.parseInt(c1) - gh2);
				productStatus42.setProductivity(decimalFormat.format((double) gh2 * 100 / Integer.parseInt(c1)) + "%");
			}
			productStatus42.setCompleteAmount(gh2);
			productStatusList4.add(productStatus42);
			ProductStatus productStatus43 = new ProductStatus();
			productStatus43.setPname("1080组件");
			int gh3 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("1080".equals(solid.getStube().substring(3, 7))) {
					gh3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus43.setPlanAmount(0);
				productStatus43.setLastPlanAmount(0 - gh3);
				productStatus43.setProductivity(0 + "");
			} else {
				productStatus43.setPlanAmount(Integer.parseInt(d1));
				productStatus43.setLastPlanAmount(Integer.parseInt(d1) - gh3);
				productStatus43.setProductivity(decimalFormat.format((double) gh3 * 100 / Integer.parseInt(d1)) + "%");
			}
			productStatus43.setCompleteAmount(gh3);
			productStatusList4.add(productStatus43);
			ProductStatus productStatus44 = new ProductStatus();
			productStatus44.setPname("1060组件");
			int gh4 = 0;
			for (int i = 0; i < ghList.size(); i++) {
				Solid solid = ghList.get(i);
				if ("1060".equals(solid.getStube().substring(3, 7))) {
					gh4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus44.setPlanAmount(0);
				productStatus44.setLastPlanAmount(0 - gh4);
				productStatus44.setProductivity(0 + "");
			} else {
				productStatus44.setPlanAmount(Integer.parseInt(e1));
				productStatus44.setLastPlanAmount(Integer.parseInt(e1) - gh4);
				productStatus44.setProductivity(decimalFormat.format((double) gh4 * 100 / Integer.parseInt(e1)) + "%");
			}
			productStatus44.setCompleteAmount(gh4);
			productStatusList4.add(productStatus44);
			stationStatus4.setProductStatusList(productStatusList4);
			stationStatusList.add(stationStatus4);
			// 计算切割工位每个产品的生产状况
			StationStatus stationStatus5 = new StationStatus();
			stationStatus5.setStationName(stationName[4]);
			List<ProductStatus> productStatusList5 = new ArrayList<>();
			ProductStatus productStatus51 = new ProductStatus();
			productStatus51.setPname("0960外压组件");
			int qg1 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("0960".equals(cut.getCtube().substring(3, 7))) {
					qg1++;
				}
			}
			if ("".equals(b1) || b1 == null) {
				productStatus51.setPlanAmount(0);
				productStatus51.setLastPlanAmount(0 - qg1);
				productStatus51.setProductivity(0 + "");
			} else {
				productStatus51.setPlanAmount(Integer.parseInt(b1));
				productStatus51.setLastPlanAmount(Integer.parseInt(b1) - qg1);
				productStatus51.setProductivity(decimalFormat.format((double) qg1 * 100 / Integer.parseInt(b1)) + "%");
			}
			productStatus51.setCompleteAmount(qg1);
			productStatusList5.add(productStatus51);
			ProductStatus productStatus52 = new ProductStatus();
			productStatus52.setPname("0980外压组件");
			int qg2 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("0980".equals(cut.getCtube().substring(3, 7))) {
					qg2++;
				}
			}
			if ("".equals(c1) || c1 == null) {
				productStatus52.setPlanAmount(0);
				productStatus52.setLastPlanAmount(0 - qg2);
				productStatus52.setProductivity(0 + "");
			} else {
				productStatus52.setPlanAmount(Integer.parseInt(c1));
				productStatus52.setLastPlanAmount(Integer.parseInt(c1) - qg2);
				productStatus52.setProductivity(decimalFormat.format((double) qg2 * 100 / Integer.parseInt(c1)) + "%");
			}
			productStatus52.setCompleteAmount(qg2);
			productStatusList5.add(productStatus52);
			ProductStatus productStatus53 = new ProductStatus();
			productStatus53.setPname("1080组件");
			int qg3 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("1080".equals(cut.getCtube().substring(3, 7))) {
					qg3++;
				}
			}
			if ("".equals(d1) || d1 == null) {
				productStatus53.setPlanAmount(0);
				productStatus53.setLastPlanAmount(0 - qg3);
				productStatus53.setProductivity(0 + "");
			} else {
				productStatus53.setPlanAmount(Integer.parseInt(d1));
				productStatus53.setLastPlanAmount(Integer.parseInt(d1) - qg3);
				productStatus53.setProductivity(decimalFormat.format((double) qg3 * 100 / Integer.parseInt(d1)) + "%");
			}
			productStatus53.setCompleteAmount(qg3);
			productStatusList5.add(productStatus53);
			ProductStatus productStatus54 = new ProductStatus();
			productStatus54.setPname("1060组件");
			int qg4 = 0;
			for (int i = 0; i < qgList.size(); i++) {
				Cut cut = qgList.get(i);
				if ("1060".equals(cut.getCtube().substring(3, 7))) {
					qg4++;
				}
			}
			if ("".equals(e1) || e1 == null) {
				productStatus54.setPlanAmount(0);
				productStatus54.setLastPlanAmount(0 - qg4);
				productStatus54.setProductivity(0 + "");
			} else {
				productStatus54.setPlanAmount(Integer.parseInt(e1));
				productStatus54.setLastPlanAmount(Integer.parseInt(e1) - qg4);
				productStatus54.setProductivity(decimalFormat.format((double) qg4 * 100 / Integer.parseInt(e1)) + "%");
			}
			productStatus54.setCompleteAmount(qg4);
			productStatusList5.add(productStatus54);
			stationStatus5.setProductStatusList(productStatusList5);
			stationStatusList.add(stationStatus5);
			stationStatusList.get(0).setNumber(number);
			return stationStatusList;
		} else {
			// 排产单不存在
			return stationStatusList;
		}

	}

	@Override
	public String Comprehensivenumber(Map<String, Object> map) {
		return weeklyreport.Comprehensivenumber(map);
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	@Override
	public Workstation Comprehensiveday(String time, String team) throws ParseException {
		Position msposition = positionMapper.getPositionByPname("膜丝");
		Position zzposition = positionMapper.getPositionByPname("组装");
		Position lxposition = positionMapper.getPositionByPname("离心");
		Position ghposition = positionMapper.getPositionByPname("拆端盖");
		Position qgposition = positionMapper.getPositionByPname("切割");
		


		Map<String, Object> map = new HashMap();
		
		Map<String, Object> map12 = new HashMap();
		
		Map<String, Object> maptime = new HashMap();
		DecimalFormat decimalFormat = new DecimalFormat(".00");
		Workstation workstation = new Workstation();
		workstation.setTime(time);
		workstation.setTeam(team);
		String timesd;
		
		// 获取班组号
		Long tids = weeklyproductionreport.PlanId(team);
		// 班组查订单
		
		map.put("sid", tids);
		map.put("Dates", time);
		
		

		String plan = weeklyreport.Dayreport(map);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Map<String, Object> map1 = new HashMap<>();
		
		TeamRecord teamRecord =new TeamRecord();
		teamRecord.setTeamId(tids);
		teamRecord.setTtime(time);
		teamRecord=teamRecordMapper.getTeamRecordByTeamRecord(teamRecord);
		workstation.setTeam(teamRecord.getRemark01());
		
		
		
		List<Classes> classesByName = classesService.getClassesByName("白班");
		Classes cla = classesByName.get(0);
		//白班的开始时间（小时） 
		Integer startTime = Integer.parseInt(cla.getStartTime().substring(0,2));
		int Bi=Integer.parseInt(teamRecord.getRemark02().substring(0, 2));
		int Ei=Integer.parseInt(teamRecord.getRemark03().substring(0, 2));
		if(Bi>Ei) {
			map.put("beginTime", time +" "+ teamRecord.getRemark02());
			Date begin = null;
			try {
				begin = sdf.parse(time);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			Calendar cc = Calendar.getInstance();
			cc.setTime(begin);
			cc.add(Calendar.DAY_OF_MONTH, 1);
			String endtime = sdf.format(cc.getTime());
			map.put("endTime", endtime + " "+teamRecord.getRemark03());
		}else {
			
			if(Ei<=startTime) {
				String timess=time;
				 SimpleDateFormat sdfd = new SimpleDateFormat("yyyy-MM-dd");
			      Date timesss =  sdfd.parse(timess);
			      
			      Calendar ca = Calendar.getInstance();//得到一个Calendar的实例 
					ca.setTime(timesss); //设置时间为当前时间
					ca.add(Calendar.DATE, 1);
					Date last = ca.getTime();
					 timesd = sdf.format(last);
					 map.put("sid", tids);
				     map.put("Dates", timesd);
				//workstation.setTime(timesd);
				map.put("beginTime", timesd + " "+teamRecord.getRemark02());
				map.put("endTime", timesd + " "+teamRecord.getRemark03());
			}else {
				map.put("beginTime", time + " "+teamRecord.getRemark02());
				map.put("endTime", time + " "+teamRecord.getRemark03());
			}
			
		}

		if (null != plan) {
			SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			Shedudetail shedudetail = weeklyreport.Planreport(Long.parseLong(plan));
			if (null != shedudetail) {
				
			
				List<MousseBundleSample> msList = allReportMapper.listAllMSByTime(map);// 膜丝
				List<Assemble> zzList = allReportMapper.listAllZZByTime(map);// 组装
				List<Centrifugal> lxList = allReportMapper.listAllLXByTime(map);// 离心
				List<Solid> ghList = allReportMapper.listAllGHByTime(map);// 固化
				
				List<Cut> qgList = weeklyreport.listAllCutByTimes(map);// 切割
				//List<Cut> qgList = allReportMapper.listAllCutByTime(map);// 切割
				
				String a9601 = shedudetail.getC09601();// 膜丝数量
				String a9602 = shedudetail.getC09602();// 膜丝数量
				
				String a9801 = shedudetail.getC09801();// 膜丝数量
				String a9802 = shedudetail.getC09802();// 膜丝数量
				
				String a9603 = shedudetail.getC09603();// 膜丝数量
				String a9604 = shedudetail.getC09604();// 膜丝数量
				
				String a9803 = shedudetail.getC09803();// 膜丝数量
				String a9804 = shedudetail.getC09804();// 膜丝数量
				
				String a10601 = shedudetail.getC10601();// 膜丝数量
				String a10602 = shedudetail.getC10602();// 膜丝数量
				
				String a10801 = shedudetail.getC10801();// 膜丝数量
				String a10802 = shedudetail.getC10802();// 膜丝数量
				
				
				String a4 = shedudetail.getA4();// 组装数量
				String a7 = shedudetail.getA7();// 离心数量
				String a8 = shedudetail.getA8();// 固化数量
				String a10 = shedudetail.getA10();// 切割数量
				WorkstationDetail workstationdetail01 = new WorkstationDetail();
				WorkstationDetail workstationdetail02 = new WorkstationDetail();
				WorkstationDetail workstationdetail03 = new WorkstationDetail();
				WorkstationDetail workstationdetail04 = new WorkstationDetail();
				WorkstationDetail workstationdetail05 = new WorkstationDetail();
				WorkstationDetail workstationdetail06 = new WorkstationDetail();
				WorkstationDetail workstationdetailzz = new WorkstationDetail();
				WorkstationDetail workstationdetaillx = new WorkstationDetail();
				WorkstationDetail workstationdetailgh = new WorkstationDetail();
				WorkstationDetail workstationdetailqg = new WorkstationDetail();
				// 膜丝 热法1
				int ms1 = 0;
				for (int i = 0; i < msList.size(); i++) {
					MousseBundleSample mousseBundleSample = msList.get(i);
					if ("01".equals(mousseBundleSample.getMbscode().substring(4, 6))) {
						ms1++;
					}
				}
				if (("".equals(a9601) || a9601 == null)&&("".equals(a9801) || a9801 == null)) {
					workstationdetail01.setId(shedudetail.getRemark1());
					workstationdetail01.setTheory("0");
					workstationdetail01.setDifference("0");
					workstation.setHot1(workstationdetail01);
				} else {
					if(("".equals(a9601) || a9601 == null)) {
						a9601="0";
					}
					if(("".equals(a9801) || a9801 == null)) {
						a9801="0";
					}
					int b9601=Integer.parseInt(a9601);
					int b9801=Integer.parseInt(a9801);
					workstationdetail01.setFact(ms1 + "");
					workstationdetail01.setId(shedudetail.getRemark1());
					workstationdetail01.setTheory((b9601+b9801) * 24 + "");
					String baifen = decimalFormat.format((double) ms1 * 100 / ((b9601+b9801) * 24)) + "%";
					if (baifen.equals(".00%")) {
						workstationdetail01.setDifference("0.00%");
					} else {
						workstationdetail01.setDifference(baifen);
					}
					workstation.setHot1(workstationdetail01);
				}

				// 膜丝 热法2
				int ms2 = 0;
				for (int i = 0; i < msList.size(); i++) {
					MousseBundleSample mousseBundleSample = msList.get(i);
					if ("02".equals(mousseBundleSample.getMbscode().substring(4, 6))) {
						ms2++;
					}
				}
				if (("".equals(a9602) || a9602 == null)&&("".equals(a9802) || a9802 == null)) {
					workstationdetail02.setId(shedudetail.getRemark1());
					workstationdetail02.setTheory("0");
					workstationdetail02.setDifference("0");
					workstation.setHot2(workstationdetail02);
					
				} else {
					
					if(("".equals(a9602) || a9602 == null)) {
						a9602="0";
					}
					if(("".equals(a9802) || a9802 == null)) {
						a9802="0";
					}
					int b9602=Integer.parseInt(a9602);
					int b9802=Integer.parseInt(a9802);
					
					workstationdetail02.setId(shedudetail.getRemark1());
					workstationdetail02.setFact(ms2 + "");
					workstationdetail02.setTheory((b9602+b9802) * 24 + "");
					String baifen = decimalFormat.format((double) ms2 * 100 / ((b9602+b9802) * 24)) + "%";
					if (baifen.equals(".00%")) {
						workstationdetail02.setDifference("0.00%");
					} else {
						workstationdetail02.setDifference(baifen);
					}
					workstation.setHot2(workstationdetail02);
				}

				// 膜丝 热法3
				int ms3 = 0;
				for (int i = 0; i < msList.size(); i++) {
					MousseBundleSample mousseBundleSample = msList.get(i);
					if ("03".equals(mousseBundleSample.getMbscode().substring(4, 6))) {
						ms3++;
					}
				}
				if (("".equals(a9603) || a9603 == null)&&("".equals(a9803) || a9803 == null)) {
					workstationdetail03.setId(shedudetail.getRemark1());
					workstationdetail03.setTheory("0");
					workstationdetail03.setDifference("0");
					workstation.setHot3(workstationdetail03);
					
				} else {
					
					if(("".equals(a9603) || a9603 == null)) {
						a9603="0";
					}
					if(("".equals(a9803) || a9803 == null)) {
						a9803="0";
					}
					int b9603=Integer.parseInt(a9603);
					int b9803=Integer.parseInt(a9803);
					
					workstationdetail03.setId(shedudetail.getRemark1());
					workstationdetail03.setFact(ms3 + "");
					workstationdetail03.setTheory((b9603+b9803) * 24 + "");
					String baifen = decimalFormat.format((double) ms3 * 100 / ((b9603+b9803) * 24)) + "%";
					if (baifen.equals(".00%")) {
						workstationdetail03.setDifference("0.00%");
					} else {
						workstationdetail03.setDifference(baifen);
					}
					workstation.setHot3(workstationdetail03);
				}

				// 膜丝 热法4
				int ms4 = 0;
				for (int i = 0; i < msList.size(); i++) {
					MousseBundleSample mousseBundleSample = msList.get(i);
					if ("04".equals(mousseBundleSample.getMbscode().substring(4, 6))) {
						ms4++;
					}
				}
				if (("".equals(a9604) || a9604 == null)&&("".equals(a9804) || a9804 == null)) {
					workstationdetail04.setId(shedudetail.getRemark1());
					workstationdetail04.setTheory("0");
					workstationdetail04.setDifference("0");
					workstation.setHot4(workstationdetail04);
					
				} else {
					
					if(("".equals(a9604) || a9604 == null)) {
						a9604="0";
					}
					if(("".equals(a9804) || a9804 == null)) {
						a9804="0";
					}
					int b9604=Integer.parseInt(a9604);
					int b9804=Integer.parseInt(a9804);
					
					workstationdetail04.setId(shedudetail.getRemark1());
					workstationdetail04.setFact(ms4 + "");
					workstationdetail04.setTheory((b9604+b9804) * 24 + "");
					String baifen = decimalFormat.format((double) ms4 * 100 / ((b9604+b9804) * 24)) + "%";
					if (baifen.equals(".00%")) {
						workstationdetail04.setDifference("0.00%");
					} else {
						workstationdetail04.setDifference(baifen);
					}
					workstation.setHot4(workstationdetail04);
				}

				// 膜丝 湿法1
				int ms5 = 0;
				for (int i = 0; i < msList.size(); i++) {
					MousseBundleSample mousseBundleSample = msList.get(i);
					if ("05".equals(mousseBundleSample.getMbscode().substring(4, 6))) {
						ms5++;
					}
				}
				if (("".equals(a10601) || a10601 == null)&&("".equals(a10801) || a10801 == null)) {
					workstationdetail05.setId(shedudetail.getRemark1());
					workstationdetail05.setTheory("0");
					workstationdetail05.setDifference("0");
					workstation.setWet1(workstationdetail05);
					
				} else {
					
					if(("".equals(a10601) || a10601 == null)) {
						a10601="0";
					}
					if(("".equals(a10801) || a10801 == null)) {
						a10801="0";
					}
					int b10601=Integer.parseInt(a10601);
					int b10801=Integer.parseInt(a10801);
					
					workstationdetail05.setId(shedudetail.getRemark1());
					workstationdetail05.setFact(ms5 + "");
					workstationdetail05.setTheory((b10601+b10801) * 32 + "");
					String baifen = decimalFormat.format((double) ms5 * 100 / ((b10601+b10801) * 32)) + "%";
					if (baifen.equals(".00%")) {
						workstationdetail05.setDifference("0.00%");
					} else {
						workstationdetail05.setDifference(baifen);
					}
					workstation.setWet1(workstationdetail05);
				}
				// 膜丝 湿法2
				int ms6 = 0;
				for (int i = 0; i < msList.size(); i++) {
					MousseBundleSample mousseBundleSample = msList.get(i);
					if ("06".equals(mousseBundleSample.getMbscode().substring(4, 6))) {
						ms6++;
					}
				}
				if (("".equals(a10602) || a10602 == null)&&("".equals(a10802) || a10802 == null)) {
					workstationdetail06.setId(shedudetail.getRemark1());
					workstationdetail06.setTheory("0");
					workstationdetail06.setDifference("0");
					workstation.setWet2(workstationdetail06);
					
				} else {
					
					if(("".equals(a10602) || a10602 == null)) {
						a10602="0";
					}
					if(("".equals(a10802) || a10802 == null)) {
						a10802="0";
					}
					int b10602=Integer.parseInt(a10602);
					int b10802=Integer.parseInt(a10802);
					
					workstationdetail06.setId(shedudetail.getRemark1());
					workstationdetail06.setTheory(((b10602+b10802)) * 32 + "");
					workstationdetail06.setFact(ms6 + "");
					String baifen = decimalFormat.format((double) ms6 * 100 / ((b10602+b10802) * 32)) + "%";
					if (baifen.equals(".00%")) {
						workstationdetail06.setDifference("0.00%");
					} else {
						workstationdetail06.setDifference(baifen);
					}
					workstation.setWet2(workstationdetail06);
				}

				// 组装
				int zz1 = 0;
				int zz2 = 0;
				for (int i = 0; i < zzList.size(); i++) {

					String str = zzList.get(i).getAtube().substring(3, 5);
					if ("09".equals(str)) {
						zz1++;
					}
					if ("10".equals(str)) {
						zz2++;
					}
				}
				if ("".equals(a4) || a4 == null) {
					workstationdetailzz.setId(shedudetail.getRemark1());
					workstationdetailzz.setTheory("0");
					workstationdetailzz.setDifference("0");
					workstation.setAssemble(workstationdetailzz);
				} else {
					workstationdetailzz.setId(shedudetail.getRemark1());
					int zz3 = (zz1 / 24) + (zz2 / 32);
					workstationdetailzz.setTheory((Integer.parseInt(a4)) + "");
					String baifen = decimalFormat.format((double) zz3 * 100 / (Integer.parseInt(a4))) + "%";
					if (baifen.equals(".00%")) {
						workstationdetailzz.setDifference("0.00%");
					} else {
						workstationdetailzz.setDifference(baifen);
					}
					workstationdetailzz.setFact(zz3 + "");
					workstation.setAssemble(workstationdetailzz);
				}
				// 离心
				int lx1 = 0;
				for (int i = 0; i < lxList.size(); i++) {
					lx1++;
				}
				if ("".equals(a7) || a7 == null) {
					workstationdetaillx.setId(shedudetail.getRemark1());
					workstationdetaillx.setTheory("0");
					workstationdetaillx.setDifference("0");
					workstation.setCentrifugal(workstationdetaillx);
				} else {
					workstationdetaillx.setId(shedudetail.getRemark1());
					workstationdetaillx.setTheory((Integer.parseInt(a7)) + "");
					String baifen = decimalFormat.format((double) lx1 * 100 / (Integer.parseInt(a7))) + "%";
					if (baifen.equals(".00%")) {
						workstationdetaillx.setDifference("0.00%");
					} else {
						workstationdetaillx.setDifference(baifen);
					}
					workstationdetaillx.setFact(lx1 + "");
					workstation.setCentrifugal(workstationdetaillx);
				}

				// 固化
				int gh1 = 0;
				for (int i = 0; i < ghList.size(); i++) {
					gh1++;
				}
				if ("".equals(a8) || a8 == null) {
					workstationdetailgh.setId(shedudetail.getRemark1());
					workstationdetailgh.setTheory("0");
					workstationdetailgh.setDifference("0");
					workstation.setSolid(workstationdetailgh);
				} else {
					workstationdetailgh.setId(shedudetail.getRemark1());
					workstationdetailgh.setTheory((Integer.parseInt(a8)) + "");
					String baifen = decimalFormat.format((double) gh1 * 100 / (Integer.parseInt(a8))) + "%";
					if (baifen.equals(".00%")) {
						workstationdetailgh.setDifference("0.00%");
					} else {
						workstationdetailgh.setDifference(baifen);
					}
					workstationdetailgh.setFact(gh1 + "");
					workstation.setSolid(workstationdetailgh);
				}
				// 切割
				int qg1 = 0;
				for (int i = 0; i < qgList.size(); i++) {
					qg1++;
				}
				if ("".equals(a10) || a10 == null) {
					workstationdetailqg.setId(shedudetail.getRemark1());
					workstationdetailqg.setTheory("0");
					workstationdetailqg.setDifference("0");
					workstation.setCut(workstationdetailqg);
				} else {
					workstationdetailqg.setId(shedudetail.getRemark1());
					workstationdetailqg.setTheory((Integer.parseInt(a10)) + "");
					String baifen = decimalFormat.format((double) qg1 * 100 / (Integer.parseInt(a10))) + "%";
					if (baifen.equals(".00%")) {
						workstationdetailqg.setDifference("0.00%");
					} else {
						workstationdetailqg.setDifference(baifen);
					}
					workstationdetailqg.setFact(qg1 + "");
					workstation.setCut(workstationdetailqg);
				}
				// 膜丝产线
				List<Worktimes> worktimes = weeklyreport.Comprehensiveworks(map);
				List<Assemble> worktimeszz = weeklyreport.Comprehensiveworksassemble(map);
				List<Solid> worktimesgh = weeklyreport.Comprehensiveworkssolid(map);
				List<Centrifugal> worktimeslx = weeklyreport.Comprehensiveworkscentrifugal(map);
				List<Cut> worktimesqg = weeklyreport.Comprehensiveworkscut(map);
				Set<String> uidms01 = new HashSet<>();
				Set<String> uidms02 = new HashSet<>();
				Set<String> uidms03 = new HashSet<>();
				Set<String> uidms04 = new HashSet<>();
				Set<String> uidms05 = new HashSet<>();
				Set<String> uidms06 = new HashSet<>();
				Set<String> uidzz = new HashSet<>();
				Set<String> uidlx = new HashSet<>();
				Set<String> uidgh = new HashSet<>();
				Set<String> uidqg = new HashSet<>();
				for (Worktimes s : worktimes) {
					String chanxian = s.getMbscode().substring(4, 6);
					switch (chanxian) {
					case "01":
						uidms01.add(s.getMbsremark2());
						break;
					case "02":
						uidms02.add(s.getMbsremark2());
						break;
					case "03":
						uidms03.add(s.getMbsremark2());
						break;
					case "04":
						uidms04.add(s.getMbsremark2());
						break;
					case "05":
						uidms05.add(s.getMbsremark2());
						break;
					case "06":
						uidms06.add(s.getMbsremark2());
						break;
					}
				}
				for (Assemble s : worktimeszz) {
					uidzz.add(s.getAremark2());
				}
				for (Solid s : worktimesgh) {
					uidgh.add(s.getCremark7());
				}
				for (Centrifugal s : worktimeslx) {
					uidlx.add(s.getCremark2());
				}
				for (Cut s : worktimesqg) {
					uidqg.add(s.getCremark4());
				}
				long hours = 0;
				long minutes = 0;
				long seconds = 0;
				// 热法1
				Long cha1 = 0L;
				int peo1 = uidms01.size();
				map.put("pid", msposition.getPid());
				List<Worktime> worktime1 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime1) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha1 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);

						cha1 += logout.getTime() - login.getTime();
					}
				}
				hours = cha1 / 3600000;
				minutes = (cha1 % 3600000) / 60000;
				seconds = (cha1 % 60000) / 1000;
				workstationdetail01.setPeople(peo1 + "");
				workstationdetail01.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setHot1(workstationdetail01);

				// 热法2
				Long cha2 = 0L;
				int peo2 = uidms02.size();
				List<Worktime> worktime2 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime2) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha2 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha2 += logout.getTime() - login.getTime();
					}
				}
				hours = cha2 / 3600000;
				minutes = (cha2 % 3600000) / 60000;
				seconds = (cha2 % 60000) / 1000;
				workstationdetail02.setPeople(peo2 + "");
				workstationdetail02.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setHot2(workstationdetail02);

				// 热法3工时
				Long cha3 = 0L;
				int peo3 = uidms03.size();
				List<Worktime> worktime3 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime3) {
					String loginTime = s1.getLogintime();

					Date login = sdfs.parse(loginTime);

					String logoutTime = s1.getLogouttime();

					if (null == logoutTime) {
						cha3 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha3 += logout.getTime() - login.getTime();
					}

				}
				hours = cha3 / 3600000;
				minutes = (cha3 % 3600000) / 60000;
				seconds = (cha3 % 60000) / 1000;
				workstationdetail03.setPeople(peo3 + "");
				workstationdetail03.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setHot3(workstationdetail03);

				// 热法4工时
				Long cha4 = 0L;
				int peo4 = uidms04.size();
				List<Worktime> worktime4 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime4) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha4 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha4 += logout.getTime() - login.getTime();
					}
				}
				hours = cha4 / 3600000;
				minutes = (cha4 % 3600000) / 60000;
				seconds = (cha4 % 60000) / 1000;
				workstationdetail04.setPeople(peo4 + "");
				workstationdetail04.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setHot4(workstationdetail04);
				// 湿法1工时
				Long cha5 = 0L;
				int peo5 = uidms05.size();
				List<Worktime> worktime5 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime5) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha5 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha5 += logout.getTime() - login.getTime();
					}
				}
				hours = cha5 / 3600000;
				minutes = (cha5 % 3600000) / 60000;
				seconds = (cha5 % 60000) / 1000;
				workstationdetail05.setPeople(peo5 + "");
				workstationdetail05.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setWet1(workstationdetail05);
				// 湿法2工时
				Long cha6 = 0L;
				int peo6 = uidms06.size();
				List<Worktime> worktime6 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime6) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha6 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha6 += logout.getTime() - login.getTime();
					}
				}
				// }
				hours = cha6 / 3600000;
				minutes = (cha6 % 3600000) / 60000;
				seconds = (cha6 % 60000) / 1000;
				workstationdetail06.setPeople(peo6 + "");
				workstationdetail06.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setWet2(workstationdetail06);
				// 组装
				Long cha7 = 0L;
				int peo7 = uidzz.size();
				map.put("pid", zzposition.getPid());
				List<Worktime> worktime7 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime7) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha7 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha7 += logout.getTime() - login.getTime();
					}
				}

				// }
				hours = cha7 / 3600000;
				minutes = (cha7 % 3600000) / 60000;
				seconds = (cha7 % 60000) / 1000;
				workstationdetailzz.setPeople(peo7 + "");
				workstationdetailzz.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setAssemble(workstationdetailzz);
				// 离心
				Long cha8 = 0L;
				int peo8 = uidlx.size();
				map.put("pid", lxposition.getPid());
				List<Worktime> worktime8 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime8) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha8 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha8 += logout.getTime() - login.getTime();
					}
				}
				// }
				hours = cha8 / 3600000;
				minutes = (cha8 % 3600000) / 60000;
				seconds = (cha8 % 60000) / 1000;
				workstationdetaillx.setPeople(peo8 + "");
				workstationdetaillx.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setCentrifugal(workstationdetaillx);
				// 固化
				Long cha9 = 0L;
				int peo9 = uidgh.size();
				map.put("pid", ghposition.getPid());
				List<Worktime> worktime9 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime9) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha9 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha9 += logout.getTime() - login.getTime();
					}
				}
				// }
				hours = cha9 / 3600000;
				minutes = (cha9 % 3600000) / 60000;
				seconds = (cha9 % 60000) / 1000;
				workstationdetailgh.setPeople(peo9 + "");
				workstationdetailgh.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setSolid(workstationdetailgh);
				// 切割
				Long cha10 = 0L;
				int peo10 = uidqg.size();
				map.put("pid", qgposition.getPid());
				List<Worktime> worktime10 = weeklyreport.Comprehensivework(map);
				for (Worktime s1 : worktime10) {
					String loginTime = s1.getLogintime();
					Date login = sdfs.parse(loginTime);
					String logoutTime = s1.getLogouttime();
					if (null == logoutTime) {
						cha10 += 0;
					} else {
						Date logout = sdfs.parse(logoutTime);
						cha10 += logout.getTime() - login.getTime();
					}
				}
				// }
				hours = cha10 / 3600000;
				minutes = (cha10 % 3600000) / 60000;
				seconds = (cha10 % 60000) / 1000;
				workstationdetailqg.setPeople(peo10 + "");
				workstationdetailqg.setWork(hours + "时" + minutes + "分" + seconds + "秒");
				workstation.setCut(workstationdetailqg);

			} else {
				// 无排产单 不做处理
			}
		} else {
			// 排产单空 不做处理
		}
		WorkstationDetail workstationdetailLeak = new WorkstationDetail();
		WorkstationDetail workstationdetailevalute = new WorkstationDetail();
		WorkstationDetail workstationdetailgas = new WorkstationDetail();
		List<ZcLeakHuntingEntity> Leak = weeklyreport.ComprehensiveworksLeak(map);
		List<ZcEvaluateEntity> evalute = weeklyreport.ComprehensiveworksEvaluate(map);
		List<ZcGasEntity> gas = weeklyreport.ComprehensiveworksGas(map);
		Set<String> leak1 = new HashSet<>();
		Set<String> evalute1 = new HashSet<>();
		Set<String> gas1 = new HashSet<>();
		Set<String> leak2 = new HashSet<>();
		Set<Long> evalute2 = new HashSet<>();
		Set<Long> gas2 = new HashSet<>();
		ArrayList<String> leak3 = new ArrayList<>();
		ArrayList<String> timeleak = new ArrayList<>();
		ArrayList<String> timeevalute = new ArrayList<>();
		ArrayList<String> timegas = new ArrayList<>();
		Set<String> numberleak = new HashSet<>();
		Set<String> numberevalute = new HashSet<>();
		Set<String> numbergas = new HashSet<>();
		for (ZcLeakHuntingEntity L : Leak) {
			leak1.add(L.getTestPerson());
			leak2.add(L. getLhCode());
			leak3.add(L. getLhCode());
			timeleak.add(L.getTestTime());
			numberleak.add(L.getNumber());
		}
		int fact2 = leak3.size() - leak2.size();
		workstationdetailLeak.setFact(leak2.size() + "");
		workstationdetailLeak.setPeople(leak1.size() + "");
		workstationdetailLeak.setFact2(fact2 + "");
		if (timeleak.size() > 0) {
			workstationdetailLeak.setWork(timeleak.get(0));
		} else {

		}
		workstation.setLeak(workstationdetailLeak);
		if (numberleak.size() > 0) {
			Iterator iter = numberleak.iterator();
			String x = (String) iter.next();
			maptime.put("number", x);
			String planleak = weeklyreport.ComprehensiveworkstimePlan(maptime);
			workstationdetailLeak.setId(planleak);
		}
		workstation.setLeak(workstationdetailLeak);

		for (ZcEvaluateEntity L : evalute) {
			evalute1.add(L.getTestPerson());
			evalute2.add(L.getEvId());
			timeevalute.add(L.getTestTime());
			numberevalute.add(L.getNumber());
		}
		workstationdetailevalute.setFact(evalute2.size() + "");
		workstationdetailevalute.setPeople(evalute1.size() + "");
		if (timeevalute.size() > 0) {
			workstationdetailevalute.setWork(timeevalute.get(0));
		} else {

		}
		workstation.setRun(workstationdetailevalute);
		if (numberevalute.size() > 0) {
			Iterator iter = numberevalute.iterator();
			String x = (String) iter.next();
			maptime.put("number", x);
			String planevalute = weeklyreport.ComprehensiveworkstimePlan(maptime);
			workstationdetailevalute.setId(planevalute);
		}
		workstation.setRun(workstationdetailevalute);

		for (ZcGasEntity L : gas) {
			gas1.add(L.getTestPerson());
			gas2.add(L.getgId());
			timegas.add(L.getTestTime());
			numbergas.add(L.getNumber());
		}
		workstationdetailgas.setFact(gas2.size() + "");
		workstationdetailgas.setPeople(gas1.size() + "");
		if (timegas.size() > 0) {
			workstationdetailgas.setWork(timegas.get(0));
		} else {

		}
		if (numbergas.size() > 0) {
			Iterator iter = numbergas.iterator();
			String x = (String) iter.next();
			maptime.put("number", x);
			String plangas = weeklyreport.ComprehensiveworkstimePlan(maptime);
			workstationdetailgas.setId(plangas);
		}
		workstation.setAirtight(workstationdetailgas);
		return workstation;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	@Override
	public void updatacomprehen(AllWorkstation allWorkstation) throws ParseException {

		weeklyreport.UpdataComprehen(allWorkstation);
	}

	@Override
	public List<AllWorkstation> selectcomprehen(Map<String, Object> map) throws ParseException {

		List<AllWorkstation> work = weeklyreport.SelectComprehen(map);
		return work;
	}

	@Override
	public void deletecomprehen(Map<String, Object> map) throws ParseException {
		weeklyreport.DelectComprehen(map);
	}

	@Override
	public Integer updatacomprehening(String time) throws ParseException {
		int isSuccess = 0;
		//判断时间      为空赋值为当前天
		if (null == time || time.equals("")) {
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");// 设置日期格式
			time = df.format(new Date());
		}
		Map<String, Object> map = new HashMap();
		SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM");
		Calendar calendars = Calendar.getInstance();
		
		//获取当前天
		int days = calendars.get(Calendar.DAY_OF_MONTH);// 当前天
		
		//为1查询传的上月
		if (days == 1) {
			calendars.add(Calendar.DAY_OF_MONTH, -1);
			int month = calendars.get(Calendar.MONTH) + 1;// 获取月份
			Date date = calendars.getTime();
			time = sd.format(date);
		} else
			//查询传的月
		{
			int month = calendars.get(Calendar.MONTH) + 1;// 获取月份
			Date date = calendars.getTime();
			time = sd.format(date);
		}

		//处理传的时间
		Integer years = Integer.parseInt(time.toString().substring(0, 4));
		Integer months = Integer.parseInt(time.toString().substring(5, 7));// 传的月份
		
		Calendar calendar = Calendar.getInstance();
		//获取实际当前月
		int smonth = calendar.get(Calendar.MONTH) + 1;// 当前月份
		
		
		List<Workstation> workstation = new ArrayList<>();
		
		
		//需要查询的月份  对比 实际当前月
		if (months != smonth) {// 查询其他月
			List list = new ArrayList();
			Calendar aCalendar = Calendar.getInstance();
			aCalendar.clear();
			aCalendar.set(Calendar.YEAR, years);// 设置年
			aCalendar.set(Calendar.MONTH, months);// 设置月
			
			int year = aCalendar.get(Calendar.YEAR);// 获取年份
			int month = aCalendar.get(Calendar.MONTH);// 获取月份
			
			int day = DateUtil.getDays(time);// 获取天数
			for (int i = 1; i <= day; i++) {
				String aDate = null;
				if (month < 10 && i < 10) {
					aDate = String.valueOf(year) + "-0" + month + "-0" + i;
				}
				if (month < 10 && i >= 10) {
					aDate = String.valueOf(year) + "-0" + month + "-" + i;
				}
				if (month >= 10 && i < 10) {
					aDate = String.valueOf(year) + "-" + month + "-0" + i;
				}
				if (month >= 10 && i >= 10) {
					aDate = String.valueOf(year) + "-" + month + "-" + i;
				}
				list.add(aDate);
			}
			List<TeamRecord> TeamRecord=new ArrayList<>();
			
//			TeamRecord=teamRecordMapper.getTeamRecordByTime(time);
			
			
			for (int ii = 0; ii < day; ii++) {
				TeamRecord=teamRecordMapper.getTeamRecordByTime((String)list.get(ii));
				System.out.println(list.get(ii));
				for(TeamRecord s:TeamRecord) {
					System.out.println(s.getTtime()+"///"+s.getTname());
					String teams=weeklyreport.PlanTeam(s.getTeamId());
					workstation.add(weeklyproductionreport.Comprehensiveday(list.get(ii) + "", teams));
				}
			}
//			if(workstation.size()!=0) {
//				workstation = WorkstationUtil.Sum(workstation);
//			}
//			
//			
//			map.put("begintime", list.get(0));
//			map.put("endtime", list.get(day - 1));
//			weeklyproductionreport.deletecomprehen(map);
//			for (int a = 0; a < workstation.size(); a++) {
//				AllWorkstation allWorkstation = new AllWorkstation();
//				allWorkstation.change(workstation.get(a));
////				weeklyproductionreport.updatacomprehen(allWorkstation);
//			}
			
			if(workstation.size()!=0) {
				workstation = WorkstationUtil.Sum(workstation);
				map.put("begintime", list.get(0));
				map.put("endtime", list.get(day-1));
				weeklyproductionreport.deletecomprehen(map);
//				System.out.println(time);
//				weeklyproductionreport.deletecomprehen2(time);
				for (int a = 0; a < workstation.size(); a++) {
					AllWorkstation allWorkstation = new AllWorkstation();
					allWorkstation.change(workstation.get(a));
					weeklyproductionreport.updatacomprehen(allWorkstation);
					isSuccess = 1;
				}
			}else {
				isSuccess = 2;
			}
			
			
		} else {
			// 查询本月
			List list = new ArrayList();
			Calendar aCalendar = Calendar.getInstance();
			aCalendar.clear();
			aCalendar.set(Calendar.YEAR, years);// 设置年
			aCalendar.set(Calendar.MONTH, months);// 设置月
			
			int year = aCalendar.get(Calendar.YEAR);// 获取年份
			int month = aCalendar.get(Calendar.MONTH);// 获取月份
			
			aCalendar.set(Calendar.DAY_OF_MONTH, 0);// 设置天数
			int day = calendar.get(Calendar.DAY_OF_MONTH);// 当前天数
			day = day - 1;
			for (int i = 1; i <= day; i++) {
				String aDate = null;
				if (month < 10 && i < 10) {
					aDate = String.valueOf(year) + "-0" + month + "-0" + i;
				}
				if (month < 10 && i >= 10) {
					aDate = String.valueOf(year) + "-0" + month + "-" + i;
				}
				if (month >= 10 && i < 10) {
					aDate = String.valueOf(year) + "-" + month + "-0" + i;
				}
				if (month >= 10 && i >= 10) {
					aDate = String.valueOf(year) + "-" + month + "-" + i;
				}
				list.add(aDate);
			}
			
             List<TeamRecord> TeamRecord=new ArrayList<>();
			
			
			
			
			for (int ii = 0; ii < day; ii++) {
				TeamRecord=teamRecordMapper.getTeamRecordByTime((String)list.get(ii));
				for(TeamRecord s:TeamRecord) {
					System.out.println(s.getTtime()+"///"+s.getTname());
					String teams=weeklyreport.PlanTeam(s.getTeamId());
					
					workstation.add(weeklyproductionreport.Comprehensiveday(list.get(ii) + "", teams));
				}
			}
					
			
//			
//			for (int ii = 0; ii < day; ii++) {
//				workstation.add(weeklyproductionreport.Comprehensiveday(list.get(ii) + "", "白班"));
//				workstation.add(weeklyproductionreport.Comprehensiveday(list.get(ii) + "", "晚班"));
//			}

			if(workstation.size()!=0) {
				workstation = WorkstationUtil.Sum(workstation);
				map.put("begintime", list.get(0));
				map.put("endtime", list.get(day-1));
				weeklyproductionreport.deletecomprehen(map);
//				System.out.println(time);
//				weeklyproductionreport.deletecomprehen2(time);
				for (int a = 0; a < workstation.size(); a++) {
					AllWorkstation allWorkstation = new AllWorkstation();
					allWorkstation.change(workstation.get(a));
					weeklyproductionreport.updatacomprehen(allWorkstation);
					isSuccess = 1;
				}
			}else {
				isSuccess = 2;
			}
			
		}
		return isSuccess;
	}

	

}
